﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace ProjectSem3.Admin
{
    public partial class WebForm19 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
          
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Employee emp = (Employee)Session["user"];
            string pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtEmpPassword.Text, "sha1");
            if (emp.Username.Equals(txtUser.Text) && emp.Password.Equals(pwd))
            {
                dataDataContext dc = new dataDataContext();
                emp = dc.Employees.Single(em => em.EmployeeID == emp.EmployeeID);
                emp.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(txtNewPassword.Text, "sha1");
                emp.FullName = txtName.Text;
                emp.BirthDay = DateTime.Now;
                emp.Gender = ChkGender.Checked;
                emp.Email = txtEmail.Text;
                emp.Address = txtAddress.Text;
                emp.Phone = txtPhone.Text;
                emp.TimeLogin = DateTime.Now;
                dc.SubmitChanges();
                Session.Remove("user");
                Response.Redirect("Default.aspx");

            }
            else
            {
                lblMessage.Text = "Username or password is incorrect";
            }

        }
    }
}